{% set pypi_name = 'python-swiftclient' %}
{% set upstream_version = upstream_version('3.11.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Object Storage API Client Library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('python-keystoneclient') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildArch:      noarch

%description
This is a python client for the Swift API. There's a Python API (the
swiftclient module), and a command-line script (swift).

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack Object Storage API Client Library
Requires:       {{ py3('requests') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 3.9.0
%endif

%description -n {{ py2name(py_versions='py3') }}
This is a python client for the Swift API. There's a Python API (the
swiftclient module), and a command-line script (swift).

This package contains the Python 3.x module.

%package -n python-swiftclient-doc
Summary:        %{summary} - Documentation
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n python-swiftclient-doc
This is a python client for the Swift API. There's a Python API (the
swiftclient module), and a command-line script (swift).

This package contains documentation files for %{name}.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/swiftclient
%{python3_sitelib}/*.egg-info
%{_bindir}/swift
%{_mandir}/man1/swift.1*

%files -n python-swiftclient-doc
%license LICENSE
%doc doc/build/html

%changelog
